/*
  2011 - This file is part of AcaLabelPrint 

  AcaLabelPrint is free Software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  AcaLabelprint is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with AcaLabelPrint.  If not, see <http:www.gnu.org/licenses/>.

  We encourage you to use and extend the functionality of AcaLabelPrint,
  and send us an e-mail on the outlines of the extension you build. If
  it's generic, maybe we could add it to the project.
  Send your mail to the projectadmin at http:sourceforge.net/projects/labelprint/
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
//using System.Windows.Forms;

namespace ACA.LabelX.PrintEngine
{
    public class PrintEngine
    {
        public PrintDocument printDocument = null;

        public bool DesignMode
        {
            set
            {
                GlobalDataStore theStore;
                theStore = GlobalDataStore.GetInstance();
                theStore.DesignMode = value;
            }
            get
            {
                GlobalDataStore theStore;
                theStore = GlobalDataStore.GetInstance();
                return theStore.DesignMode;
            }
        }

        public IDictionary<string, string> Printers = new Dictionary<string, string>();
        public List<PrintJob.PrintJob> PrintJobs = new List<PrintJob.PrintJob>();
        PrintJob.PrintJob CurrentJob = null;
        
        public String Machine = "";

        public PrintEngine(String Machine)
        {            
            this.Machine = Machine;
        }

        public void AddPrinter(string Printer)
        {
            Printers.Add(Printer, Printer);
        }

        public void AddPrintJob(PrintJob.PrintJob Job)
        {
            CurrentJob = Job;
        }

        public void Print(string DocumentName,string Printer, string Tray, string Papertype, uint FromPage, uint ToPage, int Language )
        {
            CurrentJob.Print(DocumentName,Printer, Tray, Papertype, FromPage, ToPage, Language);
        }

        public void PrintPreview(string sPrinterName, string sPapertype, string sTrayName, bool bWithBorders, uint nStartLabel, uint nEndLabel)
        {            
            CurrentJob.DrawBorders = bWithBorders;
            try
            {
                CurrentJob.PrintPreview(sPrinterName, sPapertype, sTrayName, nStartLabel, nEndLabel, 1043);
            }
            catch (ApplicationException ex)
            {
                // a printpreview is only done by UI code, so this may be done here.
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }


        // The PrintPage event is raised for each page to be printed.
        private void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            ev.HasMorePages = false;
            Pen blackPen = new Pen(Color.Black);
            ev.Graphics.DrawLine(blackPen, new Point(0, 0), new Point(100, 100));
            blackPen.Dispose();
        }
    }
}
/*
 AcaLabelPrint Copyright (C) 2011  Retailium Software Development BV.
 This program comes with ABSOLUTELY NO WARRANTY; 
 This is free Software, and you are welcome to redistribute it
 under certain conditions. See the License.txt file or 
 GNU GPL 3.0 License at <http://www.gnu.org/licenses>*/
